//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.tencent.bugly;

import android.content.Context;
import android.text.TextUtils;
import com.tencent.bugly.crashreport.CrashReport;
import com.tencent.bugly.crashreport.common.strategy.StrategyBean;
import com.tencent.bugly.crashreport.crash.BuglyBroadcastReceiver;
import com.tencent.bugly.crashreport.crash.c;
import com.tencent.bugly.proguard.n;
import com.tencent.bugly.proguard.o;
import com.tencent.bugly.proguard.x;

public class CrashModule extends a {
    public static final int MODULE_ID = 1004;
    private long a;
    private com.tencent.bugly.BuglyStrategy.a b;
    private static int c = 0;
    private boolean d = false;
    private static CrashModule e = new CrashModule();

    public CrashModule() {
    }

    public static CrashModule getInstance() {
        e.id = 1004;
        return e;
    }

    public synchronized boolean hasInitialized() {
        return this.d;
    }

    public synchronized void init(Context var1, boolean var2, BuglyStrategy var3) {
        if (var1 != null && !this.d) {
            x.a("Initializing crash module.", new Object[0]);
            n.a().a(1004, ++c);
            this.d = true;
            CrashReport.setContext(var1);
            this.a(var1, var3);
            c var7;
            (var7 = com.tencent.bugly.crashreport.crash.c.a(1004, var1, var2, this.b, (o)null, (String)null)).e();
            if (var3 != null) {
                var7.a(var3.getCallBackType());
                var7.a(var3.getCloseErrorCallback());
            }

            var7.m();
            if (var3 != null && !var3.isEnableNativeCrashMonitor()) {
                x.a("[crash] Closed native crash monitor!", new Object[0]);
                var7.f();
            } else {
                var7.g();
            }

            if (var3 != null && !var3.isEnableANRCrashMonitor()) {
                x.a("[crash] Closed ANR monitor!", new Object[0]);
                var7.i();
            } else {
                var7.h();
            }

            long var5 = var3 != null ? var3.getAppReportDelay() : 0L;
            var7.a(var5);
            var7.l();
            com.tencent.bugly.crashreport.crash.d.a(var1);
            BuglyBroadcastReceiver var8;
            (var8 = BuglyBroadcastReceiver.getInstance()).addFilter("android.net.conn.CONNECTIVITY_CHANGE");
            var8.register(var1);
            n.a().a(1004, --c);
        }
    }

    private synchronized void a(Context var1, BuglyStrategy var2) {
        if (var2 != null) {
            String var3;
            if (!TextUtils.isEmpty(var3 = var2.getLibBuglySOFilePath())) {
                com.tencent.bugly.crashreport.common.info.a.a(var1).n = var3;
                x.a("setted libBugly.so file path :%s", new Object[]{var3});
            }

            if (var2.getCrashHandleCallback() != null) {
                this.b = var2.getCrashHandleCallback();
                x.a("setted CrashHanldeCallback", new Object[0]);
            }

            if (var2.getAppReportDelay() > 0L) {
                this.a = var2.getAppReportDelay();
                x.a("setted delay: %d", new Object[]{this.a});
            }

        }
    }

    public void onServerStrategyChanged(StrategyBean var1) {
        if (var1 != null) {
            c var2;
            if ((var2 = com.tencent.bugly.crashreport.crash.c.a()) != null) {
                var2.a(var1);
            }

        }
    }

    public String[] getTables() {
        return new String[]{"t_cr"};
    }
}
